package ltd.sshine.tracking.openfeign.advice;

import feign.FeignException;
import lombok.extern.slf4j.Slf4j;
import ltd.sshine.runtime.pojo.Result;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionAdvice {
    @ExceptionHandler({FeignException.class})
    public ResponseEntity<Result<Object>> remoteException(FeignException feignException) {
        log.error("调用异常", feignException);
        return new ResponseEntity<>(Result.error("调用异常"), HttpStatusCode.valueOf(feignException.status()));
    }

}
